package com.springboot.springbootjpa.controller;

import com.springboot.springbootjpa.entity.Student;
import com.springboot.springbootjpa.repository.StudentRepositiory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class StudentHandler {

    @Autowired
    private StudentRepositiory studentRepositiory;

    @GetMapping("/findAll")
    public List<Student> findAll(){
        return studentRepositiory.findAll();
    }

    @GetMapping("/findById/{id}")
    public Student findById(@PathVariable Long id){
        return studentRepositiory.findById(id).get();
    }




}
